package cn.tedu.ivos.vehicle.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.vehicle.pojo.dto.VehicleInspectionQuery;
import cn.tedu.ivos.vehicle.pojo.entity.VehicleInspection;
import cn.tedu.ivos.vehicle.pojo.entity.VehicleRepair;
import cn.tedu.ivos.vehicle.pojo.vo.VehicleInspectionVO;
import cn.tedu.ivos.vehicle.service.VehicleInspectionService;
import cn.tedu.ivos.vehicle.service.VehicleRepairService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/vehicleInspection")
@Api(tags = "车辆年检模块")
public class VehicleInspectionController {
    @Autowired
    private VehicleInspectionService vehicleInspectionService;
    @Autowired
    private VehicleRepairService vehicleRepairService;

    @GetMapping("/select")
    public JsonResult select(VehicleInspectionQuery query){
        List<VehicleInspectionVO> vos = vehicleInspectionService.selectvehicle(query);
        return JsonResult.ok(vos);
    }

    @ApiOperation("查询车牌号")
    @GetMapping("/selectlicense")
    public JsonResult selectLicense(){
        return JsonResult.ok(vehicleRepairService.selectLicense());
    }

    @ApiOperation("新增车辆")
    @PostMapping("/insert")
    public JsonResult insert(VehicleInspection vehicleInspection){
        log.debug("vehicleRepairQuety{}",vehicleInspection);
        vehicleInspectionService.insert(vehicleInspection);
        return JsonResult.ok();

    }
    @ApiOperation("删除车辆")
    @DeleteMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Long id){
        vehicleInspectionService.deleteVehicleById(id);
        return JsonResult.ok();
    }

}
